﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Comdiv.UXmlDiff;

namespace uxmldiff
{
	public class uxmldiffProgram
	{
		public static int Main(string [] args) {
			try {
				var firstfile = args[0];
				var secondfile = args[1];
				bool safemode = false;
				if (args.Length > 2) {
					safemode = args[2] == "safe";
				}
				var oldx = XElement.Load(firstfile);
				var newx = XElement.Load(secondfile);
				var diff = new XDiffExecutor(oldx, newx).Execute(safemode);
				foreach (var a in diff) {
					Console.WriteLine(a);
				}
				return 0;
			}catch(Exception ex) {
				Console.ForegroundColor = ConsoleColor.Red;
				Console.WriteLine(ex.ToString());
				return -1;
			}
		}
	}
}
